package com.xiaoyu.im.datamodel.bridge;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.xiaoyu.im.IMCallback;
import com.xiaoyu.im.datamodel.AppMessage;
import com.xiaoyu.im.datamodel.vendors.VendorConversationUnique;

public interface MessageBridge<Message, ConversationUnique extends VendorConversationUnique, Notification> {

    @NonNull
    Message create(AppMessage appMessage);

    void recreate(AppMessage appMessage, IMCallback<Message> callback);

    /**
     * You cannot call this method on the main thread because it may potentially block it for a long time.
     */
    @NonNull
    AppMessage tryToAppMessage(Message message) throws Throwable;

    /**
     * You cannot call this method on the main thread because it may potentially block it for a long time.
     */
    @NonNull
    AppMessage tryToAppMessage(Message message, String chatId) throws Throwable;

    /**
     * You cannot call this method on the main thread because it may potentially block it for a long time.
     */
    @Nullable
    AppMessage toAppMessageOrNull(Message message);

    void toAppMessage(@NonNull Message message, IMCallback<AppMessage> callback);

    /**
     * You cannot call this method on the main thread because it may potentially block it for a long time.
     */
    @NonNull
    AppMessage tryNotificationToAppMessage(Notification notification, String chatId) throws Throwable;


    @Nullable
    ConversationUnique toConversationUnique(Message message);

    @Nullable
    ConversationUnique toConversationUnique(String chatId);

    @Nullable
    ConversationUnique notificationToConversationUnique(Notification message);
}
